package cn.lovefix.org.controller;
import cn.lovefix.base.pageList;
import cn.lovefix.org.domain.Movie;
import cn.lovefix.org.query.queryByname;
import cn.lovefix.org.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/movie")
public class MovieController {
    //删除用户
    @Autowired
    private MovieService movieService;
    @RequestMapping("/del")
    public String delete(@RequestParam Long mId){
        System.out.println(mId);
        movieService.del(mId);
        return "ok";
    }
    //新增或者修改用户
    @RequestMapping("/update")
    public String addOrUpdate(Movie movie){
        if (movie.getmId()==null){
            movieService.add(movie);
        }else {
            movieService.update(movie);
        }
        return "ok";
    }
    @ResponseBody
    @RequestMapping("/query")
    public pageList page(@RequestBody queryByname query){
        System.out.println(query.getKeyWord()+"我是keyWord");
        pageList<Movie> list = movieService.query(query);
        return list;
    }
}
